<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主机巡检报告</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-7ymO4nGrkm372HoSbq1OY2DP4pEZnMiA+E0F3zPr+JQQtQ82gQ1HPY3QIVtztVua" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        body { padding: 20px; }
        .shadow-sm { box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important; }
        .border-left { border-left: 1px solid #dee2e6; }
        .card { margin-bottom: 20px; }
        .ml-3, .ml-4 { margin-left: 1rem; }
        .ml-4 { margin-left: 2rem; }
        .list-group-item-action { cursor: pointer; }
        .list-group-item-action:focus { outline: none; }
        .fas { margin-right: 6px; }
        .collapsible-link { display: flex; align-items: center; }
        pre {font-family:幼圆; font-size: 16px; color: rgba(229, 112, 75, 0.99)}
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <!-- 左侧菜单栏 -->
        <div class="col-md-11 border-right">
            <div class="list-group">
                {% for group_name, hosts in report_data.items() %}
                <a class="list-group-item list-group-item-action collapsible-link" data-target="{{ group_name | replace(' ', '_') }}_menu" onclick="toggleCollapse(this)">
                    <i class="fas fa-chevron-right rotate-icon"></i>{{ group_name }}
                </a>
                <div id="{{ group_name | replace(' ', '_') }}_menu" class="collapse">
                    {% for host_address, questions in hosts.items() %}
                    <a class="list-group-item list-group-item-action ml-3 collapsible-link" data-target="{{ group_name | replace(' ', '_') }}_{{ host_address | replace('.', '_') }}_details" onclick="toggleCollapse(this)">
                        <i class="fas fa-server"></i>{{ host_address }}
                    </a>
                    <div id="{{ group_name | replace(' ', '_') }}_{{ host_address | replace('.', '_') }}_details" class="collapse">
                        {% for question in questions %}
                        <a class="list-group-item list-group-item-action ml-4" data-target="{{ group_name | replace(' ', '_') }}_{{ host_address | replace('.', '_') }}_{{ question.question_name | replace(' ', '_') | replace('.', '_') }}_text" onclick="toggleCollapse(this)">
                            {{ question.question_name }}
                        </a>
                        <div id="{{ group_name | replace(' ', '_') }}_{{ host_address | replace('.', '_') }}_{{ question.question_name | replace(' ', '_') | replace('.', '_') }}_text" class="collapse">
                            <div class="card shadow-sm">
                                <div class="card-body">
                                    <h6 class="card-title">{{ question.question_name }}</h6>
                                    <pre class="card-text">{{ question.question_description }}</pre>
                                </div>
                            </div>
                        </div>
                        {% endfor %}
                    </div>
                    {% endfor %}
                </div>
                {% endfor %}
            </div>
        </div>

         <!-- 右侧内容区域 -->
<!--        <div class="col-md-3">-->
<!--            {% for group_name, hosts in report_data.items() %}-->
<!--            <div class="mb-4">-->
<!--                <h4>{{ group_name }}</h4>-->
<!--                {% for host_address, questions in hosts.items() %}-->
<!--                <div>-->
<!--                    <h5>{{ host_address }}</h5>-->
<!--                    {% for question in questions %}-->
<!--                    <div id="{{ question.question_name | replace(' ', '_') | replace('.', '_') }}_text" class="collapse">-->
<!--                        <div class="card shadow-sm">-->
<!--                            <div class="card-body">-->
<!--                                <h6 class="card-title">{{ question.question_name }}</h6>-->
<!--                                <pre class="card-text">{{ question.question_description }}</pre>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    {% endfor %}-->
<!--                </div>-->
<!--                {% endfor %}-->
<!--            </div>-->
<!--            {% endfor %}-->
<!--        </div>-->
    </div>
</div>
<script>
    function toggleCollapse(element) {
        const targetId = element.getAttribute('data-target');
        const targetElement = document.getElementById(targetId);
        const icon = element.querySelector('.fa');

        // 切换折叠状态
        if (targetElement.classList.contains('collapse')) {
            targetElement.classList.remove('collapse');
            if (icon) {
                icon.classList.add('fa-rotate-90');
            }
        } else {
            targetElement.classList.add('collapse');
            if (icon) {
                icon.classList.remove('fa-rotate-90');
            }
        }

        // 切换选中状态的类
        const allMenuItems = document.querySelectorAll('.list-group-item-action');
        allMenuItems.forEach(item => {
            if (item === element) {
                item.classList.add('active');
            } else {
                item.classList.remove('active');
            }
        });
    }
</script>
</body>
</html>
